#include <REGX52.H>
void Delay(int time)		//@11.0592MHz
{
	unsigned char i, j;
	while(time--)
	{
		i = 2;
		j = 199;
		do
		{
			while (--j);
		} while (--i);
	}
}
unsigned char num[10]={0x3f, 0x30, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67};
void DisplayBoard(int location,int number,char c)
{
	switch(location)
	{
		case 8://Led 1
			P2_4=0; P2_3=0;P2_2=0; 
			break;
		case 7://Led 2
			P2_4=0; P2_3=0;P2_2=1; 
			break;
		case 6://Led 3
			P2_4=0; P2_3=1;P2_2=0; 
			break;
		case 5://Led 4
			P2_4=0; P2_3=1;P2_2=1; 
			break;
		case 4://Led 5
			P2_4=1; P2_3=0;P2_2=0; 
			break;
		case 3://Led6
		    P2_4=1; P2_3=0;P2_2=1; 
			break;
		case 2://Led 7
			P2_4=1; P2_3=1;P2_2=0; 
			break;
		case 1://Led 8
			P2_4=1; P2_3=1;P2_2=1; 
			break;
	}
	if(c=='.')
	{
		P0=num[number]^0x80;
		Delay(1);
		P0=0x00;
	}
	else
	{
		P0=num[number];
		Delay(1);
        P0=0x00;
	}
}


int main()
{
	while(1)
	{
			DisplayBoard(1,0,'0');

			DisplayBoard(2,1,'0');

			DisplayBoard(3,2,'0');

			DisplayBoard(4,3,'0');

	}
	return 0;
}